package com.mmc.delay.bean;


import com.mmc.delay.exception.DelayException;

public class TopicAndId {
    private String topic;
    private String topicId;

    public static final String COLON=":";

    public TopicAndId(String topic, String topicId) {
        this.topic = topic;
        this.topicId = topicId;
    }

    public TopicAndId(String topicAndId){
        String[] split = topicAndId.split(COLON);
        if(split.length!=2){
            throw new DelayException("检查topic格式，不能含有冒号");
        }
        this.topic=split[0];
        this.topicId=split[1];
    }

    public String getTopicAndId(){
        return topic+COLON+topicId;
    }

    public String getTopic() {
        return topic;
    }

    public String getTopicId() {
        return topicId;
    }
}
